<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body{
            height: 3000px;
        }
    </style>
</head>
<body>

    <script>
        // console.log(document.body.scrollTop)//接听不到
        window.addEventListener('scroll',function(){
            // console.log('scroll事件被触发');
            let mySscrollTop = window.pageYOffset || document.documentElement.scrollTop;//解决方法
            let mySscrollLeft = window.pageXOffset|| document.documentElement.scrollLeft;
            // console.log('垂直方向:'+document.body.scrollTop)//会触发但是数值依然是0
            console.log('垂直方向:'+mySscrollTop)


            // console.log(document.compatMode)
            // 通过输出document.compatMode确定是严格模式(CSS1Compat)还是怪异模式(BackCompat)
        })
    </script>
</body>
</html>